package com.mars.web.common.pojo;

import java.util.Map;


/**
 * 客户端响应数据
 * 
 * <p>标题: ResponseResult</p>
 * <p>描述: </p>
 * <p>公司: www.yhaoquan.com</p> 
 * @作者： 杨浩泉
 * @日期：2016年11月18日
 * @版本：1.0
 */
public class ResponseResult {

	/**
	 * 响应状态
	 */
	private Boolean status ;
	
	/**
	 * 响应代码
	 */
	private Integer code ;
	
	/**
	 * 响应消息
	 */
	private String message ;
	
	/**
	 * 响应数据
	 */
	private Object data ;
	
	/**
	 * 其他属性数据
	 */
	private Map<String, Object> attrs ;
	
	/**
	 * 当前时间
	 */
	private Long timestamp = System.currentTimeMillis() ;

	public ResponseResult() {}

	public ResponseResult(Boolean status, Integer code, String message, Object data, Map<String, Object> attrs) {
		super();
		this.status = status;
		this.code = code;
		this.message = message;
		this.data = data;
		this.attrs = attrs;
	}
	
	public static ResponseResult build(Boolean status, Integer code, String message, Object data, Map<String, Object> attrs) {
		return new ResponseResult(status, code, message, data, attrs) ;
	}
	public static ResponseResult build(Integer code, String message, Object data, Map<String, Object> attrs) {
		return new ResponseResult(null, code, message, data, attrs) ;
	}
	public static ResponseResult build(Integer code, String message, Object data) {
		return new ResponseResult(null, code, message, data, null) ;
	}
	public static ResponseResult build(Integer code, String message, Map<String, Object> attrs) {
		return new ResponseResult(null, code, message, null, attrs) ;
	}
	public static ResponseResult build(Integer code, String message) {
		return new ResponseResult(null, code, message, null, null) ;
	}
	public static ResponseResult build(Boolean status, String message, Object data, Map<String, Object> attrs) {
		return new ResponseResult(status, null, message, data, attrs) ;
	}
	public static ResponseResult build(Boolean status, String message, Object data) {
		return new ResponseResult(status, null, message, data, null) ;
	}
	public static ResponseResult build(Boolean status, String message, Map<String, Object> attrs) {
		return new ResponseResult(status, null, message, null, attrs) ;
	}
	public static ResponseResult build(Boolean status, String message) {
		return new ResponseResult(status, null, message, null, null) ;
	}
	
	public static ResponseResult build(Boolean status, Integer code, String message) {
		return new ResponseResult(status, code, message, null, null) ;
	}
	
	public static ResponseResult Ok(Boolean status, Integer code, String message, Object data, Map<String, Object> attrs) {
		return new ResponseResult(true, 200, message, data, attrs) ;
	}
	public static ResponseResult Ok(String message, Object data) {
		return new ResponseResult(true, 200, message, data, null) ;
	}
	public static ResponseResult Ok(String message, Map<String, Object> attrs) {
		return new ResponseResult(true, 200, message, null, attrs) ;
	}
	public static ResponseResult Ok(String message) {
		return new ResponseResult(true, 200, message, null, null) ;
	}
	
	public static ResponseResult failure(String message, Object data, Map<String, Object> attrs) {
		return new ResponseResult(false, 400, message, data, attrs) ;
	}
	public static ResponseResult failure(String message, Object data) {
		return new ResponseResult(false, 400, message, data, null) ;
	}
	public static ResponseResult failure(String message, Map<String, Object> attrs) {
		return new ResponseResult(false, 400, message, null, attrs) ;
	}
	public static ResponseResult failure(String message) {
		return new ResponseResult(false, 400, message, null, null) ;
	}
	
	public static ResponseResult addOk() {
		return new ResponseResult(true, 200, "添加成功", null, null) ;
	}
	public static ResponseResult addFailed() {
		return new ResponseResult(false, 400, "添加失败", null, null) ;
	}
	
	public static ResponseResult deleteOk() {
		return new ResponseResult(true, 200, "删除成功", null, null) ;
	}
	public static ResponseResult deleteFailed() {
		return new ResponseResult(false, 400, "删除失败", null, null) ;
	}
	
	public static ResponseResult updateOk() {
		return new ResponseResult(true, 200, "修改成功", null, null) ;
	}
	public static ResponseResult updateFailed() {
		return new ResponseResult(false, 400, "修改失败", null, null) ;
	}
	

	public Boolean getStatus() {
		return status;
	}

	public void setStatus(Boolean status) {
		this.status = status;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public Map<String, Object> getAttrs() {
		return attrs;
	}

	public void setAttrs(Map<String, Object> attrs) {
		this.attrs = attrs;
	}

	public Long getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(Long timestamp) {
		this.timestamp = timestamp;
	}

	@Override
	public String toString() {
		return "ResponseResult [status=" + status + ", code=" + code + ", message=" + message + ", data=" + data + ", attrs=" + attrs + ", timestamp=" + timestamp + "]";
	}
	
	
}
